import 'package:flutter/material.dart';
import 'package:draw_window/basic.dart';
import 'package:draw_window/endure.dart';
import 'package:draw_window/frame.dart';
import 'package:draw_window/glass.dart';
import 'package:flutter/services.dart';

void main(List<String> args){
  SystemChrome.setPreferredOrientations([
    DeviceOrientation.landscapeLeft,
    DeviceOrientation.landscapeRight
  ]);
  runApp(MyApp());
}


class MyApp extends StatelessWidget{

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Align(
          alignment:  Alignment.center,
          child:StateWidget(),
        ),
      ),
    );
  }
}

class StateWidget extends StatefulWidget{
  @override
  State createState() {
    return MyState();
  }
}

var control = Controller.register([
  ContainerWidget(),
  StandardFrame(),
  VerticalEndure(),
//  VerticalCenterEndure(),
  HorizontalEndure(),
//  HorizontalCenterEndure(),
//  StandardGlass(),
])
..markType = "vertical-endure";
Node tree;

class MyState extends State<StateWidget>{

  @override
  Widget build(BuildContext context) {

    var size = MediaQuery.of(context).size;

    if(size.width > size.height && tree == null){
      tree = Node(width: size.width * 0.6,
          height: size.height * 0.7,
          padding: Distance.all(6.0),
          type: "standard-frame",
          isTree: true,);
      tree.children.add([
        Node(type: "container")
      ]);
    }

    return Container(
      child: control.resolve(tree, setState),
    );
  }
}




